package org.ricks.common.db;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

/**
 * @author chenwei
 * @Title:
 * @Package
 * @Description:
 * @date 2020/12/2114:52
 */
public abstract class AbstractListHandler<T> implements ResultSetHandler<List<T>> {
    public AbstractListHandler() {
    }

    public List<T> handle(ResultSet rs) throws SQLException {
        ArrayList rows = new ArrayList();

        while(rs.next()) {
            rows.add(this.handleRow(rs));
        }

        return rows;
    }

    protected abstract T handleRow(ResultSet var1) throws SQLException;
}
